#include "WOP_Array_Entry.h"
#include "Command_Agent.h"
#include "WOPM.h"

/// 以後應要加入all_vm.h ---------------
// #include "cpvm/Composite_Pic_VM.h"
/// ------------------------------------
//這個include WOPM是經由VC ++給予的"新增include目錄"功能，把前方的路徑省略
//所以如果換其他的IDE發現路徑錯誤，請自行更改路徑。
//元件原位址:"wopm/WOPM.h"
#include <iostream>
#include <cassert>
#include <sstream>

using namespace std;

BOOL CALLBACK CompArrProc( HWND, UINT, WPARAM, LPARAM);
extern xMappingTree* mTree;
extern WOP_Entry* currentEntry;

extern HINSTANCE _hInst ;  // this instance is defined in DIVA_MAIN
extern HWND _hWnd ;        // this instance is defined in DIVA_Application

WOP_Array_Entry::WOP_Array_Entry(string s,WOP_Entry* parent){
	init(s,parent);
}
string WOP_Array_Entry::getActualPath(string name){
	assert(false);
	assert(_updated);
	return "";
	// return _refpath+name;
}

std::string WOP_Array_Entry::getGenericName()
{
	size_t index;
	string genericName = _name;
	
	char arrayIndex('i'); 
	
	for ( int i = 0; i < getDimension(); ++i )
	{
		genericName += "[$";
		genericName += arrayIndex;
		genericName += "]";
		arrayIndex++;
	}

	return genericName;
}

std::string WOP_Array_Entry::getArrayElementType()
{
	string type = getVarType();

	size_t index = type.find('(');
	size_t length = type.find(')') - index - 1;

	return type.substr(index+1, length);
}
